
import config from '../config'

export default function(url,data={},method='GET',header={}){
    return new Promise((resolve,reject)=>{
        wx.request({
          url: config.baseURL + url,
          data,
          header,
          method,
          timeout:config.timeout,
          success({statusCode,data}){
              if(~~(statusCode/100)===2 || ~~(statusCode/100)===3){
                  resolve(data)
              }
              else{
                  reject({
                      statusCode,data
                  })
              }
          },
          fail(err){
            reject(err)
          }
        })
    })
}